/*
 * This class is for simple factory.One super factory produce all product we need.
 * public:
 * 		  public Phone getPhone(PhoneBrand pb);
 */
package simpleFactoryMethod;

import bean.IPhone;
import bean.MiPhone;
import bean.Phone;
import bean.SamsungPhone;
import bean.PhoneBrand;
public class SimpleFactory {
	
	//A public method to make sure this super factory produce all we need.
	public Phone getPhone(PhoneBrand pb)//I use a enum to make sure others give us right name
	{
		//The product,the Phone is a interface
		Phone phone = null;
		
		//Switch the enum then return right product to Phone
			switch(pb)
			{
			//Here is three kind of product in PhoneBrand enum
			case MiPhone:phone = new MiPhone();break;
			case IPhone:phone = new IPhone();break;
			case SamsungPhone:phone =  new SamsungPhone();break;
			}
		return phone;
	}
}
